package org.jadestudio.home.service;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.jadestudio.home.dao.*;
import org.jadestudio.home.entity.*;

public class LeaderboardService {
	private LeaderboardDao leaderboardDao; 
	
	public LeaderboardDao getLeardBoardDao() {
		return leaderboardDao;
	}

	public void setLeaderboardDao(LeaderboardDao leaderboardDao) {
		this.leaderboardDao = leaderboardDao;
	}
	/**
	 * 获取游戏TOP10
	 * @param 
	 */
	public List<Map> getGameTop10(){
		try {
			List<Map> leaderboardList = leaderboardDao.getGameTop10();
			return leaderboardList;

		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	/**
	 * 得到最近发售的10个游戏
	 * @return
	 */
	public List<Map> getRecentGameTop10(){
		try {
			List<Map> recentGameTop10List = leaderboardDao.getRecentGameTop10List();
			return recentGameTop10List;

		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	
	/**
	 * 获取文章TOP10
	 * @param 
	 */
	public List getArticleTop10(){
		try {
			List<Map> leaderboardList = leaderboardDao.getArticleTop10();
			return leaderboardList;
			
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
	
	/*
	 * 获取游戏/文章总数
	 */
	public Map getGameArticleCount(){
		try {
			Map countMap = leaderboardDao.getGameArticleCount();
			return countMap;
			
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
	
	/**
	 * 获得指定分类游戏TOP10（按点击率排名）
	 */
	public List getGameTop10ByType(String type){
		try {
			List<java.util.Map> gameList = leaderboardDao.getGameTop10ByType(type);
			return gameList;
			
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
	/**
	 * 获得指定分类文章TOP10（按点击率排名）
	 */
	public List getArticleTop10ByType(String type){
		try {
			List<java.util.Map> gameList = leaderboardDao.getArticleTop10ByType(type);
			return gameList;
			
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}